package crivia.ecp.carry.em;

import java.util.Map;

import crivia.ecp.carry.html.table.ExcelStyle;
import crivia.ecp.carry.html.table.TDCell;
import crivia.ecp.carry.html.table.Table;
import crivia.ecp.carry.html.table.TableRow;

public class ExportTable extends Table {
	
	public ExportTable(Table table , Map<String,Short> colorMap){
		for (TableRow rf : table.getRows()){
			TableRow rt = addRow();
			for (TDCell td : rf.getCells()){
				ExcelStyle s = rt.addExcelStyle(String
						.valueOf(td.getInner())
//						.replaceAll("<br/>", "  ")
				);
				s.setColSpan(td.getColSpan()).setRowSpan(td.getRowSpan());
				s.setBgColor(colorMap.get(td.getStyle("background-color")));
				s.setFontColor(colorMap.get(td.getStyle("color")));
				if ("left".equals(td.getStyle("text-align"))){
					s.addStyle("text-align", "left");
				}
			}
		}
	}

}
